package com.barradata.app0624.validate

/**
 * Author:    WuNan
 * Email:     wunan@barradata.com
 * Created:   2019/7/13 12:37
 * Description: 数据校验扩展工具
 **/

private object PATTERN {
    const val ID_CARD = "\\d{16}"
    const val ID_CARD_BIRTHDAY = "(\\d){4}\\.\\d{2}\\.\\d{2}"
}

/**
 * 校验规则：16位数字
 */
fun String.isIdCardNumber(): Boolean {
    return this.matches(Regex(PATTERN.ID_CARD))
}

/**
 * 校验规则： yyyy.mm.dd
 */
fun String.isIdBirthday(): Boolean {
    return this.matches(Regex(PATTERN.ID_CARD_BIRTHDAY))
}